package com.gmail.blackdog1987.carcare.util;

import java.util.Date;

import com.gmail.blackdog1987.carcare.entity.TCarRent;
import com.gmail.blackdog1987.carcare.entity.TCarSale;


/**
 * 
 * @author 董国超
 *
 */
public class ModelUtil {
	public static String getCarsaleTitle(TCarSale car){
		if(car==null){
			return "";
		}
		String result = "";
		result += car.getBand()==null?"":car.getBand();
		result += car.getSeries()==null?" ":car.getSeries();
		return result;
	}
	
	public static String getCarrentTitle(TCarRent car){
		if(car==null){
			return "";
		}
		String result = "";
		result += car.getBand()==null?"":car.getBand();
		result += car.getSeries()==null?" ":car.getSeries();
		return result;
	}
	
	public static String getCarsaleInfo(TCarSale car){
		if(car==null){
			return "";
		}
		String result = "";
		if(car.getCapacity()==null||"null".equals(car.getCapacity())){
			
		}else{
			result += "/" + car.getCapacity()+"升";
		}
		if(car.getAutomatic()!=null){
			if(1==car.getAutomatic().intValue()){
				result += "/自动";
			} else{
				result += "/手动";
			}
		}
		Date buttime = new Date(car.getBuyTime());
		result += buttime.getYear()<=70?"":("/购于"+(buttime.getYear()+1900)+"年");
		result += car.getDistance()==null?"0":("/" + car.getDistance()+"万公里");
		result = result.replaceFirst("/", "");
		return result;
	}
	
	public static String getCarrentInfo(TCarRent car){
		if(car==null){
			return "";
		}
		String result = "";
		if(car.getCapacity()==null||"null".equals(car.getCapacity())){
			
		}else{
			result += "/" + car.getCapacity()+"升";
		}
		if(car.getAutomatic()!=null){
			if(1==car.getAutomatic().intValue()){
				result += "/自动";
			} else{
				result += "/手动";
			}
		}
		Date buttime = new Date(car.getBuyTime());
		result += buttime.getYear()<=70?"":("/购于"+(buttime.getYear()+1900)+"年");
		result = result.replaceFirst("/", "");
		return result;
	}
	
	public static String getCarsaleExt(TCarSale car){
		String ext = "";
		if(car.getPressure()!=null&&car.getPressure()==1){
			ext += ",胎压监测";
		}
		if(car.getAbs()!=null&&car.getAbs()==1){
			ext += ",ABS防抱死";
		}
		if(car.getEsp()!=null&&car.getEsp()==1){
			ext += ",ESP系统";
		}
		if(car.getChildSeat()!=null&&car.getChildSeat()==1){
			ext += ",儿童座椅";
		}
		if(car.getRemoteKey()!=null&&car.getRemoteKey()==1){
			ext += ",遥控钥匙";
		}
		if(car.getCruise()!=null&&car.getCruise()==1){
			ext += ",定速巡航";
		}
		if(car.getPowerSunroof()!=null&&car.getPowerSunroof()==1){
			ext += ",电动天窗";
		}
		if(car.getXenon()!=null&&car.getXenon()==1){
			ext += ",疝气大灯";
		}
		ext = ext.replaceFirst(",", "");
		return ext;
	}
	
	
	public static String getCarrentExt(TCarRent car){
		String ext = "";
		if(car.getPressure()!=null&&car.getPressure()==1){
			ext += ",胎压监测";
		}
		if(car.getAbs()!=null&&car.getAbs()==1){
			ext += ",ABS防抱死";
		}
		if(car.getEsp()!=null&&car.getEsp()==1){
			ext += ",ESP系统";
		}
		if(car.getChildSeat()!=null&&car.getChildSeat()==1){
			ext += ",儿童座椅";
		}
		if(car.getRemoteKey()!=null&&car.getRemoteKey()==1){
			ext += ",遥控钥匙";
		}
		if(car.getCruise()!=null&&car.getCruise()==1){
			ext += ",定速巡航";
		}
		if(car.getPowerSunroof()!=null&&car.getPowerSunroof()==1){
			ext += ",电动天窗";
		}
		if(car.getXenon()!=null&&car.getXenon()==1){
			ext += ",疝气大灯";
		}
		ext = ext.replaceFirst(",", "");
		return ext;
	}
}
